home *** CD-ROM | disk | FTP | other *** search
- /*
- File: GXEditStyle.c
-
- Contains:
-
- Written by: Barton R. House
-
- Copyright: © 1993 by Apple Computer, Inc., All rights reserved.
-
- */
-
- #include <Script.h>
-
- #include "GXEdit.h"
- #include "GXEditDoc.h"
- #include "GXEditStyle.h"
- #include "GXEditDebug.h"
- #include "GXEditError.h"
- #include "GXEditUtils.h"
-
- #include "math routines.h"
- #include "graphics routines.h"
- #include "graphics toolbox.h"
- #include "graphics libraries.h"
- #include "font routines.h"
- #include "layout routines.h"
- #include "layout types.h"
- #include "font menu library.h"
-
- void IncrementDocStyleRefCount(DocPtr dp, short styleIndex)
- {
- StylePtr sp;
-
- sp = GetDocStyle(dp, styleIndex);
-
- sp->refCount++;
- }
-
- void DecrementDocStyleRefCount(DocPtr dp, short styleIndex)
- {
- StylePtr sp;
-
- sp = GetDocStyle(dp, styleIndex);
-
- if(sp->refCount > 0)
- sp->refCount--;
- else
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- }
-
- StylePtr GetDocStyle(DocPtr dp, short styleIndex)
- {
- if(styleIndex < 0 || styleIndex > dp->numStyles)
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- return(&(*dp->styles)[styleIndex]);
- }
-
- short FindDocStyle(DocPtr dp, StylePtr matchSp)
- {
- short styleIndex;
- StylePtr sp;
-
- sp = *dp->styles;
-
- for(styleIndex = 0; styleIndex < dp->numStyles; styleIndex++, sp++)
- if(matchSp->textFont == sp->textFont &&
- matchSp->textSize == sp->textSize &&
- GXEqualStyle(matchSp->textStyle, sp->textStyle))
- return(styleIndex);
-
- return(-1);
-
- }
-
- void InitDocStyle(gxStyle textStyle, StylePtr newStyle)
- {
-
- newStyle->textStyle = GXCopyToStyle(nil, textStyle);
-
- newStyle->textSize = FixedToInt(GXGetStyleTextSize(newStyle->textStyle));
- newStyle->textFont = GXGetStyleFont(newStyle->textStyle);
-
- newStyle->platform = GXGetStyleEncoding(newStyle->textStyle, &newStyle->script, &newStyle->language);
-
- newStyle->refCount = 0;
-
- }
-
- short AddDocTextStyle(DocPtr dp, gxStyle textStyle)
- {
- StyleRec newStyle;
- StylePtr sp;
- short i;
-
- InitDocStyle(textStyle, &newStyle);
-
- /* try to find a style that is unreferenced -- if none found, then add it */
-
- sp = *dp->styles;
-
- for(i=0; i<dp->numStyles; i++, sp++)
- if(sp->refCount == 0) {
- GXDisposeStyle(sp->textStyle);
- BlockMove((Ptr) &newStyle, (Ptr) sp, sizeof(StyleRec));
- return(i);
- }
-
- PtrAndHand((Ptr) &newStyle, (Handle) dp->styles, sizeof(StyleRec));
-
- return(dp->numStyles++);
-
- }
-
- short SetDocStyleTextFont(DocPtr dp, short styleIndex, gxFont fontId)
- {
- StyleRec newStyle;
- long encodeIndex;
-
- newStyle = *GetDocStyle(dp, styleIndex);
-
- if(newStyle.textFont == fontId)
- return(styleIndex);
-
- newStyle.textStyle = GXCopyToStyle(nil, newStyle.textStyle);
-
- /* lets make sure the new gxFont supports the gxStyle's script/language.
- We don't have to di this if the platform is gxGlyphPlatform (script and language are meaningless)
- */
-
- if(newStyle.platform != gxGlyphPlatform && GXFindFontEncoding(fontId, newStyle.platform, newStyle.script, newStyle.language) == 0) {
-
- /* let's try one more time, this time ignoring language */
- /* NOTE: this is a tempoary hack until we figure out what the right thing to do is */
-
- if(GXFindFontEncoding(fontId, newStyle.platform, newStyle.script, gxNoLanguage) == 0) {
-
- /* oh no, we got to do something. Lets just change to the first script/language that is supported */
-
- encodeIndex = GXFindFontEncoding(fontId, gxMacintoshPlatform, gxNoScript, gxNoLanguage);
-
- GXGetFontEncoding(fontId, encodeIndex, &newStyle.script, &newStyle.language);
-
- GXSetStyleEncoding(newStyle.textStyle, gxMacintoshPlatform, newStyle.script, newStyle.language);
-
- newStyle.platform = gxMacintoshPlatform;
-
- }
-
- }
-
- GXSetStyleFont(newStyle.textStyle, fontId);
- newStyle.textFont = fontId;
-
- styleIndex = FindDocStyle(dp, &newStyle);
-
- if(styleIndex == -1)
- styleIndex = AddDocTextStyle(dp, newStyle.textStyle);
-
- GXDisposeStyle(newStyle.textStyle);
-
- return(styleIndex);
-
- }
-
- gxFont GetDocStyleTextFont(DocPtr dp, short styleIndex)
- {
- StylePtr sp;
-
- if(styleIndex < 0 || styleIndex >= dp->numStyles)
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- sp = *dp->styles + styleIndex;
-
- return(sp->textFont);
- }
-
- short SetDocStyleTextSize(DocPtr dp, short styleIndex, short size)
- {
- StyleRec newStyle;
-
- newStyle = *GetDocStyle(dp, styleIndex);
-
- if(newStyle.textSize == size)
- return(styleIndex);
-
- newStyle.textStyle = GXCopyToStyle(nil, newStyle.textStyle);
-
- GXSetStyleTextSize(newStyle.textStyle, ff(size));
-
- styleIndex = FindDocStyle(dp, &newStyle);
-
- if(styleIndex == -1)
- styleIndex = AddDocTextStyle(dp, newStyle.textStyle);
-
- GXDisposeStyle(newStyle.textStyle);
-
- return(styleIndex);
-
- }
-
- short GetDocStyleTextSize(DocPtr dp, short styleIndex)
- {
- StylePtr sp;
-
- if(styleIndex < 0 || styleIndex >= dp->numStyles)
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- sp = *dp->styles + styleIndex;
-
- return(sp->textSize);
- }
-
- short SetDocStyleFeatures(DocPtr dp, short styleIndex, short numFeatures, gxRunFeature * features)
- {
- StyleRec newStyle;
-
- newStyle = *GetDocStyle(dp, styleIndex);
-
- newStyle.textStyle = GXCopyToStyle(nil, newStyle.textStyle);
-
- GXSetStyleRunFeatures(newStyle.textStyle, numFeatures, (gxRunFeature *) features);
-
- styleIndex = FindDocStyle(dp, &newStyle);
-
- if(styleIndex == -1)
- styleIndex = AddDocTextStyle(dp, newStyle.textStyle);
-
- GXDisposeStyle(newStyle.textStyle);
-
- return(styleIndex);
- }
-
- short SetDocStyleEncoding(DocPtr dp, short styleIndex, gxFontPlatform platform, gxFontScript script, gxFontLanguage language)
- {
- StyleRec newStyle;
- long qdAppFont;
- gxFont appFont;
-
- newStyle = *GetDocStyle(dp, styleIndex);
-
- if(newStyle.platform == platform && newStyle.script == script && newStyle.language == language)
- return(styleIndex);
-
- /* first lets make sure the gxStyle's gxFont supports the script/encoding */
-
- appFont = newStyle.textFont;
-
- if(platform != gxGlyphPlatform )
- if(GXFindFontEncoding(newStyle.textFont, platform, script, language) == 0) {
-
- if(newStyle.platform == platform && newStyle.script == script && newStyle.language == gxNoLanguage)
- return(styleIndex);
-
- appFont = nil;
-
- /* let's try one more time, this time ignoring language */
- /* NOTE: this is a tempoary hack until we figure out what the right thing to do is */
-
- if(language != gxNoLanguage)
- if(GXFindFontEncoding(newStyle.textFont, platform, script, gxNoLanguage) != 0) {
- appFont = newStyle.textFont;
- language = gxNoLanguage;
- }
-
- /* Lets try to switch to the script's default gxFont */
-
- if(appFont == nil && (qdAppFont = GetScript((short) (script - 1), smScriptAppFond)) != 0)
- { gxStyle tmp = GXNewStyle();
- GXConvertQDFont(tmp, qdAppFont, 0);
- appFont = GXGetStyleFont(tmp);
- GXDisposeStyle(tmp);
- }
-
- /* if that didn't work, lets try to find a gxFont that has this scrip/language encoding */
-
- if(appFont == nil)
- GXFindFonts(nil, gxNoFontName, platform, script, language, 0, nil, 1, 1, &appFont);
-
- if(appFont == nil)
- if(GXFindFonts(nil, gxNoFontName, platform, script, gxNoLanguage,0, nil, 1, 1, &appFont) != 0)
- language = gxNoLanguage;
-
- /* if that didn't work -- something is really wrong */
-
- if(appFont == nil)
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- }
-
- newStyle.textStyle = GXCopyToStyle(nil, newStyle.textStyle);
-
- if(appFont != newStyle.textFont)
- GXSetStyleFont(newStyle.textStyle, appFont);
-
- GXSetStyleEncoding(newStyle.textStyle, platform, script, language);
-
- styleIndex = FindDocStyle(dp, &newStyle);
-
- if(styleIndex == -1)
- styleIndex = AddDocTextStyle(dp, newStyle.textStyle);
-
- GXDisposeStyle(newStyle.textStyle);
-
- return(styleIndex);
- }
-
- void GetDocStyleFeatures(DocPtr dp, short styleIndex, short * numFeatures, gxRunFeature * features)
- {
- StylePtr sp;
- long num;
-
- if(styleIndex < 0 || styleIndex >= dp->numStyles)
- gxEditPostError(dp, gx_edit_internal_fatal_error);
-
- sp = *dp->styles + styleIndex;
-
- num = GXGetStyleRunFeatures(sp->textStyle, (gxRunFeature *) features);
-
- if(numFeatures != nil)
- *numFeatures = num;
-
- }
-
- void ModifyStyleFeatures(DocPtr dp, gxFont fontId, short numFeatureGroups,
- short * srcFeatureGroupSizes,
- gxRunFeature ** srcFeatureGroups,
- short * dstFeatureGroupSizes,
- gxRunFeature ** dstFeatureGroups,
- short numStyles, short * oldStyles, short * newStyles)
- {
- short i, j, k, l;
- short numFeatures;
- gxRunFeature * features;
-
- if(numStyles == 0)
- return;
-
- /* now loop through all of the given styles */
-
- for(i = 0; i < numStyles; i++, oldStyles++, newStyles++) {
-
- *newStyles = *oldStyles; /* in case we don't match */
-
- if(GetDocStyleTextFont(dp, *oldStyles) == fontId) {
-
- GetDocStyleFeatures(dp, *oldStyles, &numFeatures, nil);
-
- features = (gxRunFeature *) NewPtr(sizeof(gxRunFeature) * numFeatures);
-
- GetDocStyleFeatures(dp, *oldStyles, nil, features);
-
- /* find feature group that matches */
-
- for(j=0; j<numFeatureGroups; j++) {
-
- if(srcFeatureGroupSizes[j] != numFeatures)
- continue;
-
- for(k=0; k<numFeatures; k++) {
-
- for(l=0; l<numFeatures; l++)
- if((srcFeatureGroups[j])[k].featureType == features[l].featureType &&
- (srcFeatureGroups[j])[k].featureSelector == features[l].featureSelector)
- break;
-
- if(l == numFeatures)
- break;
-
- }
-
- if(k == numFeatures)
- break;
- }
-
- if(j != numFeatureGroups)
- *newStyles = SetDocStyleFeatures(dp, *oldStyles,
- dstFeatureGroupSizes[j], dstFeatureGroups[j]);
-
- DisposePtr((Ptr) features);
-
- }
-
- /* increment the reference count temporarily so that the new style does not get wiped out
- if another new style is created */
-
- IncrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- /* decrement the reference counts */
-
- newStyles -= numStyles;
- for(i=0; i< numStyles; i++, newStyles++)
- DecrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- void ModifyStyleVariations(DocPtr dp, gxFont fontId, short numVariations, gxFontVariation * variations,
- short numStyles, short * oldStyles, short * newStyles)
- {
- StyleRec newStyle;
- short i,j,k;
- short numFontVariations;
- gxFontVariation ** newVariations;
- gxFontVariation * vp;
- gxFontVariation * np;
-
- if(numStyles == 0)
- return;
-
- /* now loop through all of the given styles */
-
- for(i = 0; i < numStyles; i++, oldStyles++, newStyles++) {
-
- *newStyles = *oldStyles; /* in case we dont match */
-
- /* get the soon to be old variations */
-
- newStyle = *GetDocStyle(dp, *oldStyles);
-
- if(newStyle.textFont == fontId) {
-
- newStyle.textStyle = GXCopyToStyle(nil,newStyle.textStyle);
-
- numFontVariations = GXGetStyleFontVariations(newStyle.textStyle, nil);
- newVariations = (gxFontVariation **) NewHandle(sizeof(gxFontVariation) * numFontVariations);
-
- HLock((Handle) newVariations);
-
- GXGetStyleFontVariations(newStyle.textStyle, *newVariations);
-
- vp = variations;
-
- for(j=0; j<numVariations; j++, vp++) {
-
- np = *newVariations;
-
- for(k=0; k<numFontVariations; k++, np++)
- if(np->name == vp->name) {
- np->value = vp->value;
- break;
- }
-
- if(k == numFontVariations) {
-
- /* we need to add it */
-
- HUnlock((Handle) newVariations);
-
- numFontVariations++;
- SetHandleSize((Handle) newVariations, sizeof(gxFontVariation) * numFontVariations);
-
- HLock((Handle) newVariations);
-
- (*newVariations)[numFontVariations-1] = *vp;
-
- }
-
- }
-
- #ifdef debugging
- GXIgnoreGraphicsNotice(font_variations_already_set);
- #endif
-
- GXSetStyleFontVariations(newStyle.textStyle, numFontVariations, *newVariations);
-
- #ifdef debugging
- GXPopGraphicsNotice();
- #endif
-
- *newStyles = FindDocStyle(dp, &newStyle);
-
- if(*newStyles == -1)
- *newStyles = AddDocTextStyle(dp, newStyle.textStyle);
-
- HUnlock((Handle) newVariations);
-
- GXDisposeStyle(newStyle.textStyle);
- DisposeHandle((Handle) newVariations);
-
- }
-
- /* increment the reference count temporarily so that the new style does not get wiped out
- if another new style is created */
-
- IncrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- /* decrement the reference counts */
-
- newStyles -= numStyles;
- for(i=0; i< numStyles; i++, newStyles++)
- DecrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- void ModifyStyleRunControls(DocPtr dp, gxRunControls * newRunControls, gxRunControls * runControlsMask,
- short numStyles, short * oldStyles, short * newStyles)
- {
- gxRunControls runControls;
- StyleRec newStyle;
- short i;
- char * dst;
- long size;
-
- if(numStyles == 0)
- return;
-
- /* now loop through all of the given styles */
-
- for(i = 0; i < numStyles; i++, oldStyles++, newStyles++) {
-
- *newStyles = *oldStyles; /* in case we don't match */
-
- /* get the soon to be old run features */
-
- newStyle = *GetDocStyle(dp, *oldStyles);
-
- newStyle.textStyle = GXCopyToStyle(nil, newStyle.textStyle);
-
- if(!GXGetStyleRunControls(newStyle.textStyle, &runControls)) {
-
- /* initialize gxStyle run control to default values -- all zeros */
-
- size = sizeof(runControls);
- dst = (char *) &runControls;
-
- while(size--)
- *dst++ = 0;
-
- }
-
- if(gxEditSetBitMaskOp(newRunControls, &runControls, runControlsMask, sizeof(runControls))) {
-
- GXSetStyleRunControls(newStyle.textStyle, &runControls);
-
- *newStyles = FindDocStyle(dp, &newStyle);
-
- if(*newStyles == -1)
- *newStyles = AddDocTextStyle(dp, newStyle.textStyle);
-
- }
-
- GXDisposeStyle(newStyle.textStyle);
-
- /* increment the reference count temporarily so that the new style does not get wiped out
- if another new style is created */
-
- IncrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- /* decrement the reference counts */
-
- newStyles -= numStyles;
- for(i=0; i< numStyles; i++, newStyles++)
- DecrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- void ModifyStyleTextFonts(DocPtr dp, short numFonts, gxFont * srcFonts, gxFont * dstFonts,
- short numStyles, short * oldStyles, short * newStyles)
- {
- short i, j;
- gxFont font;
-
- if(numStyles == 0)
- return;
-
- /* now loop through all of the given styles */
-
- for(i = 0; i < numStyles; i++, oldStyles++, newStyles++) {
-
- /* incase we don't match */
-
- *newStyles = *oldStyles;
-
- font = GetDocStyleTextFont(dp, *oldStyles);
-
- for(j=0; j<numFonts; j++)
- if(srcFonts[j] == font)
- break;
-
- if(j != numFonts)
- *newStyles = SetDocStyleTextFont(dp,*oldStyles, dstFonts[j]); /* in case we don't match */
-
- /* increment the reference count temporarily so that the new style does not get wiped out
- if another new style is created */
-
- IncrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- /* decrement the reference counts */
-
- newStyles -= numStyles;
- for(i=0; i< numStyles; i++, newStyles++)
- DecrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- void ModifyStyleTextSize(DocPtr dp, short textSize, short numStyles, short * oldStyles, short * newStyles)
- {
- short i;
-
- if(numStyles == 0)
- return;
-
- /* now loop through all of the given styles */
-
- for(i = 0; i < numStyles; i++, oldStyles++, newStyles++) {
-
- *newStyles = SetDocStyleTextSize(dp,*oldStyles, textSize); /* in case we don't match */
-
- /* increment the reference count temporarily so that the new style does not get wiped out
- if another new style is created */
-
- IncrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- /* decrement the reference counts */
-
- newStyles -= numStyles;
- for(i=0; i< numStyles; i++, newStyles++)
- DecrementDocStyleRefCount(dp, *newStyles);
-
- }
-
- void UnionStyleFeatures(DocPtr dp, short numStyles, short *styles,
- gxFont fontId, short * numFeatureGroupsPtr,
- short *** featureGroupSizesPtr,
- gxRunFeature **** featureGroupsPtr)
- {
- short numFeatureGroups;
- gxRunFeature *** featureGroups;
- short ** featureGroupSizes;
- short numFeatures;
- gxRunFeature * features;
- short i, j, k, l;
-
- numFeatureGroups = 0;
- featureGroups = (gxRunFeature ***) NewHandle(0);
- featureGroupSizes = (short **) NewHandle(0);
-
- for(i=0; i<numStyles; i++, styles++) {
-
- if(GetDocStyleTextFont(dp, *styles) != fontId)
- continue;
-
- /* get the feature group for the gxStyle */
-
- GetDocStyleFeatures(dp, *styles, &numFeatures, nil);
-
- features = (gxRunFeature *) NewPtr(sizeof(gxRunFeature) * numFeatures);
-
- GetDocStyleFeatures(dp, *styles, nil, features);
-
- /* try to find the feature set in our list of feature sets */
-
- for(j=0; j<numFeatureGroups; j++) {
-
- if((*featureGroupSizes)[j] != numFeatures)
- continue;
-
- for(k=0; k<numFeatures; k++) {
-
- for(l=0; l<numFeatures; l++)
- if(((*featureGroups)[j])[k].featureType == features[l].featureType &&
- ((*featureGroups)[j])[k].featureSelector == features[l].featureSelector)
- break;
-
- if(l == numFeatures)
- break;
- }
-
- if(k == numFeatures)
- break;
-
- }
-
- /* if it was not found, then add to our group of feature sets */
-
- if(j == numFeatureGroups) {
-
- PtrAndHand((Ptr) &features, (Handle) featureGroups, sizeof(gxRunFeature *));
- PtrAndHand((Ptr) &numFeatures, (Handle) featureGroupSizes, sizeof(short));
- numFeatureGroups++;
-
- } else {
-
- DisposePtr((Ptr) features);
-
- }
-
- }
-
- *numFeatureGroupsPtr = numFeatureGroups;
- *featureGroupSizesPtr = featureGroupSizes;
- *featureGroupsPtr = featureGroups;
-
- }
-
- void UnionStyleVariations(DocPtr dp, short numStyles, short *styles,
- gxFont fontId, short * numInstancesPtr,
- short *** instanceSizesPtr, gxFontVariation **** instancesPtr)
- {
- gxFontVariation * variation;
- short numStyleVariations;
- gxFontVariation * styleVariations;
- gxFontVariation * styleVariation;
- short i, j, k;
- short * stylePtr;
- StyleRec aStyle;
- short numInstances;
- gxFontVariation *** instances, ** instance;
- short ** instanceSizes;
-
- numInstances = 0;
- instances = (gxFontVariation ***) NewHandle(0);
- instanceSizes = (short **) NewHandle(0);
-
- stylePtr = styles;
-
- for(i=0; i<numStyles; i++, stylePtr++) {
-
- aStyle = *GetDocStyle(dp, *stylePtr);
-
- if(aStyle.textFont != fontId)
- continue;
-
- numStyleVariations = GXGetStyleFontVariations(aStyle.textStyle, nil);
-
- styleVariations = (gxFontVariation *) NewPtr((numStyleVariations) * sizeof(gxFontVariation));
-
- GXGetStyleFontVariations(aStyle.textStyle, styleVariations);
-
-
- /* try to find this instance among the list of instances */
-
- instance = *instances;
-
- for(j=0; j<numInstances; j++, instance++) {
-
- if((*instanceSizes)[j] != numStyleVariations)
- continue;
-
- variation = *instance;
- styleVariation = styleVariations;
-
- for(k=0; k<numStyleVariations; k++, variation++, styleVariation++)
- if(variation->name != styleVariation->name ||
- variation->value != styleVariation->value)
- break;
-
- if(k != numStyleVariations)
- continue;
-
- break;
-
- }
-
- if(j == numInstances) {
-
- PtrAndHand((Ptr) &styleVariations, (Handle) instances, sizeof(gxFontVariation *));
- PtrAndHand((Ptr) &numStyleVariations, (Handle) instanceSizes, sizeof(short));
- numInstances++;
-
- } else {
-
- DisposePtr((Ptr) styleVariations);
-
- }
-
- }
-
- *numInstancesPtr = numInstances;
- *instanceSizesPtr = instanceSizes;
- *instancesPtr = instances;
-
- }
-
- void UnionStyleRunControls(DocPtr dp, short numStyles, short *styles,
- gxRunControls * runControls, gxRunControls * runControlsMask)
- {
- short i;
- short * stylePtr;
- char * dst;
- long size;
- gxRunControls styleRunControls;
- Boolean firstTime;
- StyleRec aStyle;
-
- stylePtr = styles;
- firstTime = true;
-
- for(i=0; i<numStyles; i++, stylePtr++) {
-
- aStyle = *GetDocStyle(dp, *stylePtr);
-
- if(!GXGetStyleRunControls(aStyle.textStyle, &styleRunControls)) {
-
- /* set the default values -- all zeros */
-
- size = sizeof(styleRunControls);
- dst = (char *) &styleRunControls;
-
- while(size--)
- *dst++ = 0;
-
- }
-
- gxEditGetBitMaskOp(&styleRunControls, runControls, runControlsMask,
- sizeof(styleRunControls), firstTime);
-
- firstTime = false;
- }
-
- /* fix up the mask */
-
- if(~runControlsMask->beforeWithStreamShift)
- runControlsMask->beforeWithStreamShift = 0;
-
- if(~runControlsMask->afterWithStreamShift)
- runControlsMask->afterWithStreamShift = 0;
-
- if(~runControlsMask->crossStreamShift)
- runControlsMask->crossStreamShift = 0;
-
- if(~runControlsMask->imposedWidth)
- runControlsMask->imposedWidth = 0;
-
- if(~runControlsMask->track)
- runControlsMask->track = 0;
-
- if(~runControlsMask->hangingInhibitFactor)
- runControlsMask->hangingInhibitFactor = 0;
-
- if(~runControlsMask->kerningInhibitFactor)
- runControlsMask->kerningInhibitFactor = 0;
-
- if(~runControlsMask->decompositionAdjustmentFactor)
- runControlsMask->decompositionAdjustmentFactor = 0;
-
- if(~runControlsMask->baselineType)
- runControlsMask->baselineType = 0;
-
- }
-
- void UnionFontRunControls(DocPtr dp, short numStyles, short *styles, gxFont fontId,
- gxRunControls * runControls, gxRunControls * runControlsMask)
- {
- short i;
- short * stylePtr;
- char * dst;
- long size;
- gxRunControls styleRunControls;
- Boolean firstTime;
- StyleRec aStyle;
-
- stylePtr = styles;
- firstTime = true;
-
- for(i=0; i<numStyles; i++, stylePtr++) {
-
- if(GetDocStyleTextFont(dp, *stylePtr) != fontId)
- continue;
-
- aStyle = *GetDocStyle(dp, *stylePtr);
-
- if(!GXGetStyleRunControls(aStyle.textStyle, &styleRunControls)) {
-
- /* set the default values -- all zeros */
-
- size = sizeof(styleRunControls);
- dst = (char *) &styleRunControls;
-
- while(size--)
- *dst++ = 0;
-
- }
-
- gxEditGetBitMaskOp(&styleRunControls, runControls, runControlsMask,
- sizeof(styleRunControls), firstTime);
-
- firstTime = false;
- }
-
- /* fix up the mask */
-
- if(~runControlsMask->beforeWithStreamShift)
- runControlsMask->beforeWithStreamShift = 0;
-
- if(~runControlsMask->afterWithStreamShift)
- runControlsMask->afterWithStreamShift = 0;
-
- if(~runControlsMask->crossStreamShift)
- runControlsMask->crossStreamShift = 0;
-
- if(~runControlsMask->imposedWidth)
- runControlsMask->imposedWidth = 0;
-
- if(~runControlsMask->track)
- runControlsMask->track = 0;
-
- if(~runControlsMask->hangingInhibitFactor)
- runControlsMask->hangingInhibitFactor = 0;
-
- if(~runControlsMask->kerningInhibitFactor)
- runControlsMask->kerningInhibitFactor = 0;
-
- if(~runControlsMask->decompositionAdjustmentFactor)
- runControlsMask->decompositionAdjustmentFactor = 0;
-
- if(~runControlsMask->baselineType)
- runControlsMask->baselineType = 0;
-
- }
-